/*
 * 	Additional function for forms.html
 *	Written by ThemePixels	
 *	http://themepixels.com/
 *
 *	Copyright (c) 2012 ThemePixels (http://themepixels.com)
 *	
 *	Built for Amanda Premium Responsive Admin Template
 *  http://themeforest.net/category/site-templates/admin-templates
 */

jQuery(document).ready(function(){
	
	///// FORM TRANSFORMATION /////
	jQuery('input:checkbox, input:radio, select.uniformselect, input:file').uniform();
	jQuery("#empBirth").datepicker({ 
		dateFormat: "yy-mm-dd",
		changeYear: true,
		changeMonth: true
	});
	
	jQuery("#upload").uploadPreview({
		imgPreview: "#empPhoto",
		width: 120,
		height: 150,
		imgType: ["bmp", "gif", "png", "jpg"]
	}); 
	
	jQuery("#deptId").change(function(){
		var deptId = jQuery("#deptId").val();
		jQuery.ajax({
			type: "post",
			url: "/post/postsByDept",
			dataType: "json",
			data: {deptId: deptId},
			success: function(data) {
				console.log(data);
				jQuery("#postId").html("");
				jQuery("#postId").append("<option value=''>--请选择--</option>");
				jQuery.each(data.posts,function(i, post){
					console.log(post);
					jQuery("#postId").append("<option value='"+post.postId +"'>"+ post.postName + "</option>");
				});
			}
		});
	});
});